package com.sino.tb.auditing.entity;

import java.sql.*;

public class DeclareType {
	private String key;
	private String name;
	private String note;
	private DeclareTypeDetail[] items;
	private String type;
	private String link;

	public static DeclareType find(String key, Connection conn) {
		DeclareType dt = new DeclareType();
		String sql = "SELECT    * " +
					 "FROM      T_ST_DECLARE_TYPE " +
					 "WHERE     c_seq =  ? AND c_sys_flag = 1 ";
		try {
			PreparedStatement pstmt = conn.prepareStatement(sql);
			pstmt.setString(1, key);
			ResultSet rs = pstmt.executeQuery();
			if (rs.next()) {
				dt.setKey(rs.getString("c_seq"));
				dt.setName(rs.getString("c_name"));
				dt.setNote(rs.getString("c_notes"));
				dt.setType(rs.getString("c_type"));
				dt.setLink(rs.getString("c_url"));
			}
			rs.close();
			pstmt.close();
			DeclareTypeDetail[] dtd = DeclareTypeDetail.findAll(key, conn);
			dt.setItems(dtd);
		} catch (Exception e) {
			e.printStackTrace();
		}

		return dt;
	}

	public String getKey() {
		return key;
	}

	public void setKey(String key) {
		this.key = key;
	}

	public String getName() {
		return name;
	}

	public void setName(String name) {
		this.name = name;
	}

	public String getNote() {
		return note;
	}

	public void setNote(String note) {
		this.note = note;
	}

	public DeclareTypeDetail[] getItems() {
		return items;
	}

	public void setItems(DeclareTypeDetail[] items) {
		this.items = items;
	}

	public String getType() {
		return type;
	}

	public void setType(String type) {
		this.type = type;
	}

	public String getLink() {
		return link;
	}

	public void setLink(String link) {
		this.link = link;
	}
}
